import { CommonModule } from '@angular/common';
import { ErrorHandler, NgModule, Optional, SkipSelf } from '@angular/core';

import { throwIfAlreadyLoaded } from './guards/module-import-guard.service';
import { AppSettingService } from './services/app-setting.service';
import { AuthenticationService } from './services/authentication.service';
import { CommonService } from './services/common.service';
import { ConfigService } from './services/config.service';
import { DataSharingService } from './services/data-sharing.service';
import { ElectronService } from './services/electron.service';
import { GlobalErrorHandlerService } from './services/global-error-handler.service';
import { HttpRequestService } from './services/http-request.service';
import { MessageService } from './services/message.service';
import { PendingHttpRequestService } from './services/pending-http-request.service';
import { TokenService } from './services/token.service';
import { ValidatorFactoryService } from './services/validator-factory.service';

@NgModule({
    declarations: [],
    imports: [
        CommonModule
    ],
    providers: [
        AppSettingService,
        AuthenticationService,
        CommonService,
        ConfigService,
        DataSharingService,
        ElectronService,
        HttpRequestService,
        MessageService,
        PendingHttpRequestService,
        TokenService,
        ValidatorFactoryService,
        {
            provide: ErrorHandler,
            useClass: GlobalErrorHandlerService
        }
    ]
})
export class CoreModule {
    constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
        throwIfAlreadyLoaded(parentModule, 'CoreModule');
    }
}